<?php

require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';
require_once BaseUtil::getModulePath('customer').'/services/CustomerService.php';

class CommentForm extends BaseForm {

	public function __construct( $comments ){
        parent::__construct();
        
        $this->setAction(HttpUtil::getUrl("customer", "savecomments"));
        
        $id = new Zend_Form_Element_Hidden('id');
        $id->setValue( $comments['id'] );
        $this->addElement($id);
        
        $rcontent = new Zend_Form_Element_Textarea('rcontent');
        $rcontent->setValue( $comments['rcontent'] );
        $rcontent->setAttribs(array("rows" => 3, "cols" => 50));
        $rcontent->setLabel($this->translate->_('rcontent'));
        $this->addElement($rcontent);
        
        $this->setElementDecorators(array(
            'ViewHelper',
            array(array('div' => 'HtmlTag'), array('tag' => 'div',"class" => "form_element")),
        ));
	}
	
};

class CommentAddForm extends BaseForm{
    
    public function __construct()
    {
        parent::__construct();
        
        $this->setAction(HttpUtil::getUrl("customer", "subaddcomment"));
        
        $customerService = new CustomerService();
        $invalidUser = $customerService->getRandomInvalidUser();
        
        $commentUserId = new Zend_Form_Element_Text("userId");
        $commentUserId->setLabel($this->translate->_("userId"));
        $commentUserId->setValue($invalidUser["id"]);
        $commentUserId->addValidator("Digits");
        $commentUserId->setRequired(true);
        
        $point = new Zend_Form_Element_Text("point");
        $point->setLabel($this->translate->_("point"));
        $point->setValue(5);
        $point->addValidator("Digits");
        $betValidator = new Zend_Validate_Between(1, 5, true);
        $point->addValidator($betValidator);
        $point->setRequired(true);
        
        $productId = new Zend_Form_Element_Text("productId");
        $productId->setLabel($this->translate->_("productId"));
        $productId->addValidator("Digits");
        $productId->setRequired(true);
        
        $showInProduct = new Zend_Form_Element_Radio("showInProduct");
        $showInProduct->setLabel($this->translate->_("showInProduct"));
        $showInProduct->addMultiOption(1, $this->translate->_("inProductShow"));
        $showInProduct->addMultiOption(0, $this->translate->_("inProductUnshow"));
        $showInProduct->setValue(1);
        $showInProduct->setRequired(true);
        
        $commentText = new Zend_Form_Element_Textarea("commentText");
        $commentText->setLabel($this->translate->_("commentText"));
        $commentText->setAttribs(array("rows"=>6,"cols"=>30));
        $commentText->addFilter("StringTrim");
        $commentText->setRequired(true);
        
        $replyText = new Zend_Form_Element_Textarea("replyText");
        $replyText->setLabel($this->translate->_("replyText"));
        $replyText->setAttribs(array("rows"=>6,"cols"=>30));
        $replyText->addFilter("StringTrim");
        $replyText->setRequired(true);
        
        $this->addElements(array($commentUserId, $point, $productId, 
                                 $commentText,$replyText, $showInProduct));
        $this->setElementDecorators(array ('ViewHelper',array(array('div' =>'HtmlTag'),array('tag' =>'div',"class" => "form_element" ))));
        
    }
}

?>
